package com.supermap.dataHandling.restFul;

/**
 * Created by bruce on 18/2/3 -- 17:05
 * ____    ____  ___      .__   __.   _______        __   __   _______
 * \   \  /   / /   \     |  \ |  |  /  _____|      |  | |  | |   ____|
 * \   \/   / /  ^  \    |   \|  | |  |  __        |  | |  | |  |__
 * \_    _/ /  /_\  \   |  . `  | |  | |_ | .--.  |  | |  | |   __|
 * |  |  /  _____  \  |  |\   | |  |__| | |  `--'  | |  | |  |____
 * |__| /__/     \__\ |__| \__|  \______|  \______/  |__| |_______|
 */
public class ResultManger {
    public static ResultEntity success(Object object) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(ResultStatus.SUCCESS.getCode());
        resultEntity.setMsg(ResultStatus.SUCCESS.getMessage());
        resultEntity.setData(object);
        return resultEntity;
    }

    public static ResultEntity success() {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(ResultStatus.SUCCESS.getCode());
        resultEntity.setMsg(ResultStatus.SUCCESS.getMessage());
        resultEntity.setData(null);
        return resultEntity;
    }

    public static ResultEntity error() {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(ResultStatus.FAIL.getCode());
        resultEntity.setMsg(ResultStatus.FAIL.getMessage());
        return resultEntity;
    }

    public static ResultEntity error(String msg) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(ResultStatus.FAIL.getCode());
        resultEntity.setMsg(msg);
        return resultEntity;
    }

    public static ResultEntity error(ResultStatus resultStatus) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(resultStatus.getCode());
        resultEntity.setMsg(resultStatus.getMessage());
        return resultEntity;
    }

    public static ResultEntity error(ResultStatus resultStatus, String errorMsg) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(resultStatus.getCode());
        resultEntity.setMsg(resultStatus + ":" + errorMsg);
        return resultEntity;
    }

    public static ResultEntity error(Integer code, String message) {
        ResultEntity resultEntity = new ResultEntity();
        resultEntity.setCode(code);
        resultEntity.setMsg(message);
        return resultEntity;
    }
}
